

// 是否为空
function isEmpty(obj) {
  if (typeof (obj) == "undefined" || (!obj && typeof (obj) != "undefined" && obj != 0)) {
    return true;
  }
  for (let i in obj) {
    return false;
  }
  return true;
}
// 提示错误信息
function showError(title) {
  var app = getApp();
  wx.showToast({
    title: title,
    // icon: 'success',
    image: '../../images/icon-warn.png',    
    duration: 1500
  })
}

// 提示信息
function showStatus(title) {
  var app = getApp();
  wx.showToast({
    title: title,
    // icon: 'success',
    duration: 1500
  })
}

// 加载中..
function showLoading(loading) {
  wx.showLoading({
    title: loading,
  })
}
// 取消加载中..
function hiddenLoading() {
  wx.hideLoading()
}

// 验证手机号
function validateMobile(mobile) {

  if (this.isEmpty(mobile)) {
    return false;
  }

  if (mobile.length == 0) {
    return false;
  }
  if (mobile.length != 11) {
    return false;
  }
  var reg = /^1[3|4|5|7|8][0-9]{9}$/;
  if (!reg.test(mobile)) {
    return false;
  }
  return true;
}


module.exports = {
  isEmpty: isEmpty,
  showError: showError,
  hiddenLoading: hiddenLoading,
  showLoading: showLoading,
  validateMobile: validateMobile,
  showStatus: showStatus,
}